package com.miaosha;

import com.miaosha.bean.User;
import com.miaosha.dao.UserMapper;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@SpringBootApplication
@RestController
@MapperScan("com.miaosha.dao")
public class App {

    @Autowired
    private UserMapper userMapper;
    @RequestMapping("/")
    @ResponseBody
    public String hello() {
        User user = userMapper.selectByPrimaryKey(10);
        if (user == null){
            return "用户为空！";
        }
        return user.getName();
    }

    public static void main(String[] args) {
        System.out.println("Hello World!");
        SpringApplication.run(App.class, args);
    }
}
